package com.duowan.realtime.thrift;

import java.util.LinkedList;
import java.util.List;

import junit.framework.Assert;

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

public class HelloServiceClient {

	public static void main(String[] args) throws TException {
		// 设置调用的服务地址为本地，端口为 7911
		TTransport transport = new TSocket("127.0.0.1", 8888);
		//TTransport transport = new TFramedTransport(new TSocket("127.0.0.1", 8888));
		transport.open();
		// 设置传输协议为 TBinaryProtocol
		TProtocol protocol = new TBinaryProtocol(transport);
		final Hello.Client client = new Hello.Client(protocol);
		int size = 10000;
		List<String> resultList = new LinkedList<String>();
		// 调用服务的 helloVoid 方法
		for (int i = 0; i < 10; i++) {
			new Thread(new Runnable() {
				
				@Override
				public void run() {
						try {
							String result = client.helloString("param" + 0);
						} catch (TException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					
				}
			}).start();
		}
		
		System.out.println(resultList.size());
		//Assert.assertEquals(size, resultList.size());
		transport.close();
		
	}
	
}
